import { _decorator, Component, find, Label, Node, Sprite, SpriteFrame } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LevelItem')
export class LevelItem extends Component {

    Label: Label = null;
    Icon: Sprite = null;
    LevelNum: number = 0;
    Lock: Node = null;
    IsUnlock: boolean = false;

    protected onLoad(): void {
        this.Label = find("Label", this.node).getComponent(Label);
        this.Icon = find("Icon", this.node).getComponent(Sprite);
        this.Lock = find("lock", this.node);
    }

    init(level: number, sf: SpriteFrame) {
        this.LevelNum = level;
        this.Label.string = `第 ${level} 关`;
        this.Icon.spriteFrame = sf;
    }

    unlock() {
        this.Lock.active = false;
        this.IsUnlock = true;
    }
}

